package org.mx.dal;

import org.mx.dal.entity.Base;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@ToString
@SuppressWarnings("javadoc")
public class BaseEntity implements Base {
    /**
	 * 
	 */
	private static final long serialVersionUID = -6147776486800840264L;
	private @Getter @Setter String id;
    private @Getter @Setter long createdTime;
    private @Getter @Setter long updatedTime;
    private @Getter @Setter String operator;
    private int valid = 1;

    /**
     * {@inheritDoc}
     *
     * @see Object#equals(Object)
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        BaseEntity that = (BaseEntity) o;
        if (id != null ? !id.equals(that.id) : that.id != null) {
            return false;
        } else {
            return true;
        }
    }

    /**
     * {@inheritDoc}
     *
     * @see Object#hashCode()
     */
    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        return result;
    }

    /**
     * {@inheritDoc}
     *
     * @see Base#getValid()
     */
    @Override
    public int getValid() {
        return valid;
    }

    /**
     * {@inheritDoc}
     *
     * @see Base#setValid(int)
     */
    @Override
    public void setValid(int valid) {
        this.valid = valid;
    }
}
